package com.btshop.file.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName SwaggerConfig
 * @Description Swagger2-ui 配置类
 * @Author by nike
 * @Date 2020/7/14 23:03
 * @Version V1.0
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        /**
         * swagger-ui 访问地址：ip:端口/swagger-ui.html
         * swagger-bootstrap-ui 访问地址：ip:端口/doc.html
         */
        ApiInfo apiInfo = new ApiInfoBuilder().title("电商项目-文件服务接口") // 网站标题
                .description("文件服务接口api文档") // 网站描述
                .version("v1.0") // 版本
                .contact(new Contact("nike", "http://www.btshop.com", "422623415@qq.com")) // 联系人
                .license("The Apache License") // 协议
                .licenseUrl("http://www.apache.org/licenses/example-NOTICE.txt") // 协议url
                .build();

        return new Docket(DocumentationType.SWAGGER_2) // swagger版本
                .pathMapping("/").select()
                // 扫描那些controller
                .apis(RequestHandlerSelectors.basePackage("com.btshop.file.controller"))
                .paths(PathSelectors.any()).build().apiInfo(apiInfo);
    }
}
